"""
BeaverFramework Core Framework Module

This module provides the core Framework class that manages the overall simulation environment
for wind turbine analysis. It coordinates the assembly setup and execution process.

Authors:
    MichaelZhang

Usage:
    framework = Framework()
    framework.setup(my_assembly)
    framework.run()
"""

import numpy as np
import matplotlib.pyplot as plt
import yaml

"""
authors @ MicahelZhang
"""
class Framework:
    """
    The core framework class for managing wind turbine simulations.
    
    This class serves as the main entry point for running wind turbine simulations.
    It manages the setup and execution of assemblies, which contain the actual
    simulation models and their interactions.

    Attributes:
        assembly: The assembly object containing the simulation models
    """

    def __init__(self):
        """
        Initialize a new Framework instance.
        
        The framework starts with no assembly attached. An assembly must be added
        using the setup() method before running any simulations.
        """
        self.assembly = None

    def setup(self, assembly):
        """
        Set up the framework with an assembly.

        This method initializes the framework with an assembly and prepares it
        for execution by calling the assembly's setup method.

        Args:
            assembly: The assembly object to be used in this framework.
                     Must implement setup() and run() methods.
        """
        self.assembly = assembly
        self.assembly.setup()
        

    def run(self):
        """
        Execute the simulation using the configured assembly.

        This method runs the simulation by executing the assembly's run method.
        It ensures that an assembly has been properly set up before execution.

        Raises:
            ValueError: If no assembly has been set up before calling run().
        """
        if self.assembly:
            self.assembly.run()
        else:
            raise ValueError("No assembly has been set up.")

